//============================================================
// Producnt name:		Wz
// Version: 			1.0
// Coded by:			Wz (13066628480@163.com)
// Auto generated at: 	2016/10/9 10:22:03
//============================================================

using System;
using System.Collections.Generic;
using System.Text;
using Cloud.Model;
using System.Data.SqlClient;
using System.Data;
namespace Cloud.DAL
{
	public static class Classification_Appeal1Service
	{
		#region SqlCommandText
		private const string Save_CommandText = "insert into Classification_Appeal1 values(@name,@item1,@item2)";
		private const string Update_CommandText = "Update Classification_Appeal1 set name = @name,item1 = @item1,item2 = @item2 where id = @id";
		private const string Delete_CommandText = "delete from Classification_Appeal1 where id = @id";
		private const string FindAll_CommandText = "select * from Classification_Appeal1";
		private const string FindById_CommandText = "select * from Classification_Appeal1 where id=@id";
        private const string FindByName_CommandText = "select * from Classification_Appeal1 where Name=@Name";
        #endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region Save
		public static int Save(Classification_Appeal1 classification_Appeal1)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@name",SqlDbType.VarChar),
				new SqlParameter("@item1",SqlDbType.Int),
				new SqlParameter("@item2",SqlDbType.VarChar)
				};
			pars[0].Value=classification_Appeal1.Name;
			pars[1].Value=classification_Appeal1.Item1;
			pars[2].Value=classification_Appeal1.Item2;
	
			return DBHelper.ExecuteNonQuery(Save_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Update
		public static int Update(Classification_Appeal1 classification_Appeal1)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@id",SqlDbType.Int),
				new SqlParameter("@name",SqlDbType.VarChar),
				new SqlParameter("@item1",SqlDbType.Int),
				new SqlParameter("@item2",SqlDbType.VarChar)
				};
			pars[0].Value=classification_Appeal1.Id;
			pars[1].Value=classification_Appeal1.Name;
			pars[2].Value=classification_Appeal1.Item1;
			pars[3].Value=classification_Appeal1.Item2;
	
			return DBHelper.ExecuteNonQuery(Update_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Delete
		public static int Delete(Classification_Appeal1 classification_Appeal1)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@id",SqlDbType.Int)
				};
			pars[0].Value=classification_Appeal1.Id;
	
			return DBHelper.ExecuteNonQuery(Delete_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region FindAll
		public static IList<Classification_Appeal1> FindAll()
		{
			return CommonQuery(FindAll_CommandText,CommandType.Text,null);
		}
		#endregion
		
		#region FindById
		public static Classification_Appeal1 FindById(Int32 id)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@id",SqlDbType.Int)
			};	
			pars[0].Value = id;
			IList<Classification_Appeal1> list = CommonQuery(FindById_CommandText,CommandType.Text,pars);
			return list.Count > 0 ? list[0] : null;
		}
		#endregion

        #region FindByName
        public static Classification_Appeal1 FindByName(String Name)
        {
            SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@Name",SqlDbType.VarChar)
			};
            pars[0].Value = Name;
            IList<Classification_Appeal1> list = CommonQuery(FindByName_CommandText, CommandType.Text, pars);
            return list.Count > 0 ? list[0] : null;
        }
        #endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region CommonQuery
		private static IList<Classification_Appeal1> CommonQuery(string commandText, CommandType cmdType, SqlParameter[] pars)
		{
			IList<Classification_Appeal1> list = new List<Classification_Appeal1>();
			Classification_Appeal1 classification_Appeal1 = null;
			
			using (SqlDataReader reader = DBHelper.ExecuteQuery(commandText,cmdType,pars))
           	{
				while(reader.Read())
				{
					classification_Appeal1 = new Classification_Appeal1();
                    if (reader["id"] == null)
                    {
                        classification_Appeal1.Id = 0;
                    }
                    else
                    {
                        classification_Appeal1.Id = Convert.ToInt32(reader["id"]);
                    }

                    if (reader["name"] == null)
                    {
                        classification_Appeal1.Name = "";
                    }
                    else
                    {
                        classification_Appeal1.Name = Convert.ToString(reader["name"]);
                    }

                    if (reader["item1"] == null)
                    {
                        classification_Appeal1.Item1 = 0;
                    }
                    else
                    {
                        classification_Appeal1.Item1 = Convert.ToInt32(reader["item1"]);
                    }

                    if (reader["item2"]==null)
                    {
                        classification_Appeal1.Item2 = "";
                    }
                    else
                    {
                        classification_Appeal1.Item2 = Convert.ToString(reader["item2"]);
                    }
					
					
					list.Add(classification_Appeal1);
				}
            }
            return list;
		}
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
	}
}



